import time
from selenium import webdriver
from selenium.webdriver.common.by import By
browser = webdriver.Chrome()
browser.maximize_window()
browser.get('https://www.163.com/search')
time.sleep(1)
browser.find_element(By.CSS_SELECTOR, '#netease_search_input').send_keys('OpenAI')
browser.find_element(By.CSS_SELECTOR, '#netease_search_btn').click()
time.sleep(3)
browser.find_element(By.CSS_SELECTOR, 'div.keyword_list h3 a').click()
time.sleep(3)
print(browser.title, browser.current_url)
handles = browser.window_handles
browser.switch_to.window(handles[-1])
print(browser.title, browser.current_url)
browser.quit()
